from pages.base_page import BasePage
from selenium.webdriver.common.by import By
from config.config import HOST
"""登录首页类"""


class HomePage(BasePage):
    url = 'http://{}/crm/index.php?m=dynamic&a=index'.format(HOST) #引用base里面前半部分地址
    login_tips_locator=(By.CSS_SELECTOR,'body > div.container > div.alert.alert-success')
    clue_locator=(By.LINK_TEXT,'线索')
    dashboard_locator = (By.LINK_TEXT, "仪表盘")
    # 首页财务选项卡定位
    finance_locator = (By.LINK_TEXT, "财务")
    # 首页任务选项卡定位
    task_locator = (By.LINK_TEXT, "任务")
    # 定位首页的更多
    more_locator = (By.CSS_SELECTOR,'body > div.navbar.navbar-inverse.navbar-fixed-top > div > div > div.nav-collapse.collapse > ul:nth-child(1) > li.dropdown > a')
    # 定位知识选项
    knowledge_locator = (By.CSS_SELECTOR,'body > div.navbar.navbar-inverse.navbar-fixed-top > div > div > div.nav-collapse.collapse > ul:nth-child(1) > li.dropdown.open > ul > li:nth-child(2) > a')
    # 定位首页商机
    business_locator=(By.LINK_TEXT, "商机")
    # 获取首页的url地址
<<<<<<< HEAD

=======
    #点击合同
    click_contract_locator=(By.CSS_SELECTOR,'body > div.navbar.navbar-inverse.navbar-fixed-top > div > div > div.nav-collapse.collapse > ul:nth-child(1) > li:nth-child(7) > a')
    #点击产品
    click_product_locator=(By.CSS_SELECTOR,'body > div.navbar.navbar-inverse.navbar-fixed-top > div > div > div.nav-collapse.collapse > ul:nth-child(1) > li:nth-child(4) > a')
>>>>>>> ffa01048eb9f437ad1c34acaf41f5053bd6cf6a2
    def current_url(self):
        return self.driver.current_url

    def get_login_tips(self):
        # 获取首页的提示语，登陆成功
        tips=self.driver.find_element(*self.login_tips_locator).text
        return tips
    #点击线索
    def click_clue(self):
        self.driver.find_element(*self.clue_locator).click()

    def click_dashboard(self):
        """点击仪表盘"""
        self.driver.find_element(*self.dashboard_locator).click()

    def click_finance_tab(self):
        '''点击首页财务选项卡'''
        self.driver.find_element(*self.finance_locator).click()

    def click_task_tab(self):
        '''点击首页任务选项卡'''
        self.driver.find_element(*self.task_locator).click()

    def click_home_more(self):
        '''点击首页更多'''
        self.driver.find_element(*self.more_locator).click()

<<<<<<< HEAD
    '''点击知识按钮'''
    def click_knowledge(self):
=======
    def click_knowlege(self):
        '''点击知识按钮'''
>>>>>>> ffa01048eb9f437ad1c34acaf41f5053bd6cf6a2
        self.driver.find_element(*self.knowledge_locator).click()

    def click_business_tab(self):
        '''点击首页商机'''
        self.driver.find_element(*self.business_locator).click()

    def click_contract(self):
        """点击合同"""
        self.driver.find_element(*self.click_contract_locator).click()
    def click_product(self):
        """点击产品"""
        self.driver.find_element(*self.click_product_locator).click()



